
--[[

    slimui - Copyright (c) 2011 atom0s, All rights reserved.

    See Copyright notice in slimui.lua
    
]]--

class 'Control: Component' { ... };

----------------------------------------------------------------------------------
-- func: Control.__init__
-- desc: Constructor called when this object is first created.
----------------------------------------------------------------------------------
function Control.__init__( self )
    Component.__init__( self );
end

----------------------------------------------------------------------------------
-- func: Control:GetCaption
-- desc: Returns the caption of this control.
----------------------------------------------------------------------------------
function Control:GetCaption( )
    return control_getCaption( self._object );
end

----------------------------------------------------------------------------------
-- func: Control:SetCaption
-- desc: Sets the caption of this control.
----------------------------------------------------------------------------------
function Control:SetCaption( caption )
    control_setCaption( self._object, caption );
end

----------------------------------------------------------------------------------
-- func: Control:GetPosition
-- desc: Returns the position of this control.
----------------------------------------------------------------------------------
function Control:GetPosition( )
    return control_getPosition( self._object );
end

----------------------------------------------------------------------------------
-- func: Control:SetPosition
-- desc: Sets the position of this control.
----------------------------------------------------------------------------------
function Control:SetPosition( x, y )
    control_setPosition( self._object, x, y );
end

----------------------------------------------------------------------------------
-- func: Control:GetSize
-- desc: Returns the size of this control.
----------------------------------------------------------------------------------
function Control:GetSize( )
    return control_getSize( self._object );
end

----------------------------------------------------------------------------------
-- func: Control:SetSize
-- desc: Sets the size of this control.
----------------------------------------------------------------------------------
function Control:SetSize( width, height )
    control_setSize( self._object, width, height );
end

----------------------------------------------------------------------------------
-- func: Control:GetAlign
-- desc: Returns the alignment of this control.
----------------------------------------------------------------------------------
function Control:GetAlign( )
    return control_getAlign( self._object );
end

----------------------------------------------------------------------------------
-- func: Control:SetAlign
-- desc: Sets the alignment of this control.
----------------------------------------------------------------------------------
function Control:SetAlign( align )
    control_setAlign( self._object, align );
end

----------------------------------------------------------------------------------
-- func: Control:GetEnabled
-- desc: Returns the enabled status of this control.
----------------------------------------------------------------------------------
function Control:GetEnabled( )
    return control_getEnabled( self._object );
end

----------------------------------------------------------------------------------
-- func: Control:SetEnabled
-- desc: Sets the enabled status of this control.
----------------------------------------------------------------------------------
function Control:SetEnabled( enabled )
    control_setEnabled( self._object, enabled );
end

----------------------------------------------------------------------------------
-- func: Control:GetVisible
-- desc: Returns the visibility of this control.
----------------------------------------------------------------------------------
function Control:GetVisible( )
    return control_getVisible( self._object );
end

----------------------------------------------------------------------------------
-- func: Control:SetVisible
-- desc: Sets the visibility of this control.
----------------------------------------------------------------------------------
function Control:SetVisible( visible )
    control_setVisible( self._object, visible );
end

----------------------------------------------------------------------------------
-- func: Control:GetColor
-- desc: Returns the color of this control.
----------------------------------------------------------------------------------
function Control:GetColor( )
    return control_getColor( self._object );
end

----------------------------------------------------------------------------------
-- func: Control:SetColor
-- desc: Sets the color of this control.
----------------------------------------------------------------------------------
function Control:SetColor( color )
    control_setColor( self._object, color );
end

----------------------------------------------------------------------------------
-- func: Control:GetParent
-- desc: Returns the parent of this control.
----------------------------------------------------------------------------------
function Control:GetParent( )
    return control_getParent( self._object );
end

----------------------------------------------------------------------------------
-- func: Control:SetParent
-- desc: Sets the parent of this control.
----------------------------------------------------------------------------------
function Control:SetParent( parent )
    control_setParent( self._object );
end

----------------------------------------------------------------------------------
-- func: Control:GetPopupMenu
-- desc: Returns the popup menu object of this control.
----------------------------------------------------------------------------------
function Control:GetPopupMenu( )
    return control_getPopupMenu( self._object );
end

----------------------------------------------------------------------------------
-- func: Control:SetPopupMenu
-- desc: Sets the popup menu object of this control.
----------------------------------------------------------------------------------
function Control:SetPopupMenu( popup )
    if popup._object ~= nil then

        -- User passing a slimui object?
        local class = object_getClassName( popup._object );
        if string.lower( class ) ~= 'tpopupmenu' then
            slimui:err( 'Control:SetPopupMenu - cannot set popupmenu to non-popupmenu object!' );
        end

        control_setPopupMenu( self._object, popup._object );
    
    else
        -- Assume normal popup object.
        control_setPopupMenu( self._object, popup );
    end
end

----------------------------------------------------------------------------------
-- func: Control:OnClick
-- desc: Sets the click event function of this control.
----------------------------------------------------------------------------------
function Control:OnClick( click )
    control_onClick( self._object, click );
end




--[[ Debug information. ]]--------------------------------------------------------
if ( slimui:isdebug() == true ) then
    slimui:msg( '(Base) control.lua successfully loaded.' );
end
